/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package traffic;

import com.google.code.eventsonfire.EventHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 *
 * @author Leonardo Lino
 */
public class ControladorTrafego {
    
    
    public static final int SERVER_APP= 0;
    public static final int SERVER_DB= 1;
    public static int server;
    
    public static final int LOAD_TYPE_CONSTANT= 0;
    public static final int LOAD_TYPE_PROGRESSIVE= 1;
    private int loadType;
    
    
    
    Configuracao config;
    GeradorPanel geradorPainel;
    
    public void start(){
        launchGestorThreads();
    }
    
    private void launchGestorThreads(){
        int pedidos = geradorPainel.pedidosSlider.getValue();
        int segundos = Integer.parseInt(geradorPainel.segundosField.getText());
        int numThreads = Integer.parseInt(config.numThreadsField.getText());
        
        server = geradorPainel.comboServer.getSelectedIndex();
        
        
        Runnable task = new GestorThreads(pedidos, segundos, numThreads,
                config.checkListaTeatros.isSelected(), config.checkTeatro.isSelected());
        
       Thread worker = new Thread(task);
       worker.setName("Gestor Threads");
       worker.start();  
        
    }
    
    

    public void setConfig(Configuracao config) {
        this.config = config;
        
    }

    public void setGeradorPainel(GeradorPanel geradorPainel) {
        this.geradorPainel = geradorPainel;
        System.out.println("set gerador");
        
        int ind = geradorPainel.comboServer.getSelectedIndex();
       server = ind;
       int load = geradorPainel.comboType.getSelectedIndex();
       loadType =load;
    }
    
    
    
}
